/*
* Copyright (c) 2009 contentismissing.net, artifacts.de
*
* All rights reserved.
*
* Authors: Jens Lembke <j@contentismissing.net>;
*          Michael Markowski <m.markowski@artifacts.de>;
*
* All non-exclusive rights granted to Deutsche Telekom AG Laboratories
*
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
package net.contentismissing.tlabs.cocktailparty.behaviours
{
	import de.artifacts.multitouch.TouchEvent;
	import de.artifacts.multitouch.behaviours.TouchBehaviour;
	import flash.events.Event;
	import flash.display. * ;
	import net.contentismissing.tlabs.cocktailparty.Constants;
	import net.contentismissing.tlabs.cocktailparty.ui.SceneButton;
	public class SceneButtonBehaviour extends de.artifacts.multitouch.behaviours.TouchBehaviour
	{
		public var button : SceneButton;
		public function SceneButtonBehaviour(button : SceneButton)
		{
			this.button = button;
		}

		override public function touchedHandler(event : TouchEvent) : void
		{
			super.touchedHandler(event);
			if (event.cursor == null) return;
			if (event.cursor.touchables.indexOf(touchable) == 0)
			{
				if (touchable.doubleTap)
				{
					/**
					* Diese Funktion wird aufgerufen wenn ein DOUBEL TAP EVENT ausgelöst wird
					*/
				}else
				{
					/**
					* Dieser Event wird aufgerufen wenn ein ON TOUCH EVENT ausgelöst wird
					*/				
					(touchable.wrappee as SceneButton).onTouch();
				}
			}
		}

		/**
		* Diese Funktion wird aufgerufen wenn ein ON DRAG EVENT ausgelöst wird
		*/
		override public function repositionedHandler(event : TouchEvent) : void
		{
			super.repositionedHandler(event);
			if (event.cursor.touchables.indexOf(touchable) == 0)
			{
			}
		}

		/**
		* Diese Funktion wird aufgerufen wenn ein ON RELEASE EVENT ausgelöst wird
		*/
		override public function releasedHandler(event : TouchEvent) : void
		{
			if (event.cursor != null)
			{
				(touchable.wrappee as SceneButton).onRelease();
			}

			event.cursor = null;
		}
	}
}
